package offer;

public class offer57 {
}
class Solution57 {
    public static int[] twoSum(int[] nums, int target) {
        int start = 0;
        int end = nums.length-1;
        int [] res = new int[2];
        while (start<end)
        {
            while (start<end&&(nums[start]+nums[end])<target)
            {
               start++;
            }
            while (start<end&&(nums[start]+nums[end])>target)
            {
                end--;
            }
            if(start<end&&(nums[start]+nums[end])==target)
            {
                res[0] =nums[start];
                res[1] = nums[end];
            }
        }
        return res;
    }

    public static void main(String[] args) {
        int [] nums = {2,7,11,15};

    }
}